﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using DBUtility;
using IDAL.RF.SourceCategory;
using Model.RF.SourceCategory;

namespace DAL.RF.SourceCategory
{
    public class TemperatureCheck : BaseRepository_DT<TemperatureCheckInfo>, ITemperatureCheck
    {
        #region 静态变量部分
        private const string PARM_TEMPERATURECHECK_ID = "@ID";
        private const string PARM_TEMPERATURECHECK_PRODUCTSN = "@ProductSN";
        private const string PARM_TEMPERATURECHECK_RECORDTIME = "@RecordTime";
        private const string PARM_TEMPERATURECHECK_PRODUCTTYPEID = "@ProductTypeID";
        private const string PARM_TEMPERATURECHECK_USERID = "@UserID";
        private const string PARM_TEMPERATURECHECK_TEMPERATURE = "@Temperature";
        private const string PARM_TEMPERATURECHECK_ISPASS = "@IsPass";
        private const string PARM_TEMPERATURECHECK_REMARK = "@Remark";
        #endregion

        #region 数据检索部分
        public IList<TemperatureCheckInfo> LoadEntities()
        {
            return null;
        }

        public TemperatureCheckInfo LoadEntity<T1>(T1 id)
        {                                                      
            return null;
        }

        public IList<TemperatureCheckInfo> TemperatureCheck_GetbyProductSN(string productSN)
        {
            SqlParameter parm = new SqlParameter(PARM_TEMPERATURECHECK_PRODUCTSN, SqlDbType.NVarChar, 50);
            parm.Value = productSN;
            return ExcuteSqlToGetEntities("TemperatureCheck_selectbyProductSN", parm);
        }

        public IList<TemperatureCheckInfo> TemperatureCheck_GetbyDT(DateTime dt1,DateTime dt2)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = dt1;
            parms[1].Value = dt2;
            return ExcuteSqlToGetEntities("TemperatureCheck_selectbyDT", parms);
        }
        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override TemperatureCheckInfo GetEntityRecord(SqlDataReader rdr)
        {
            TemperatureCheckInfo pro = new TemperatureCheckInfo() 
            {
                ID=rdr.GetInt32(0),
                ProductSN=rdr.GetValue(1).ToString(),
                RecordTime=rdr.GetDateTime(2),
                ProductTypeID=rdr.GetValue(3).ToString(),
                UserID=rdr.GetValue(4).ToString(),
                Temperature=rdr.GetDecimal(5),
                IsPass=rdr.GetBoolean(6),
                Remark=rdr.GetValue(7).ToString(),
            };
            return pro;
        }

        public override TemperatureCheckInfo GetEntityRecord()
        {
            TemperatureCheckInfo pro = new TemperatureCheckInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "TemperatureCheck_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_TEMPERATURECHECK_ID, SqlDbType.NVarChar, 50);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_TEMPERATURECHECK_ID, SqlDbType.Int, 4),
					new SqlParameter(PARM_TEMPERATURECHECK_PRODUCTSN, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_TEMPERATURECHECK_RECORDTIME, SqlDbType.DateTime , 8),
					new SqlParameter(PARM_TEMPERATURECHECK_PRODUCTTYPEID, SqlDbType.NVarChar , 50),
                    new SqlParameter(PARM_TEMPERATURECHECK_USERID,SqlDbType.NVarChar,10),
                    new SqlParameter(PARM_TEMPERATURECHECK_TEMPERATURE,SqlDbType.Decimal,12),
                    new SqlParameter(PARM_TEMPERATURECHECK_ISPASS,SqlDbType.Bit,1),
                    new SqlParameter(PARM_TEMPERATURECHECK_REMARK,SqlDbType.NVarChar,200)
                };
            return parms;
        }

        public override void SetParameters(TemperatureCheckInfo tci, params SqlParameter[] Parms)
        {
            Parms[0].Value = tci.ID;
            Parms[1].Value = tci.ProductSN;
            Parms[2].Value = tci.RecordTime;
            Parms[3].Value = tci.ProductTypeID;
            Parms[4].Value = tci.UserID;
            Parms[5].Value = tci.Temperature;
            Parms[6].Value = tci.IsPass;
            Parms[7].Value = tci.Remark;
        }
        #endregion
    }
}
